<template>
  <div id="app" v-if="isRouterAlive">
    <router-view  @ischange="change"></router-view>
  </div>
</template>

<script>

export default {
  name: 'App',
  components: {
  },
  provide(){
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function() {
        this.isRouterAlive = true
      })
    },
    change() {
      // console.log('接收跳转')
      // this.reload()
      
    }
  },
  mounted() {
// 检测浏览器路由改变页面不刷新问题,hash模式的工作原理是 hashchange事件
  window.addEventListener('hashchange', () => {
      let currentPath = window.location.hash.slice(1)
      if (this.$route.path !== currentPath) {
      this.$router.push(currentPath) }
      }, false)
  }

}
</script>

<style>
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:PingFang SC,Sans GB,Arial,Microsoft YaHei,Verdana,Roboto,Noto,Helvetica Neue,sans-serif;
}
</style>
